package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingElderDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController {

    @Autowired
    NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation(value = "分页查询护理信息")
    public ResponseResult<PageResponse<NursingProjectVo>> selectByPage(
            @ApiParam(value = "页码", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "每页数量", required = true) @RequestParam Integer pageSize,
            @ApiParam(value = "姓名") @RequestParam(required = false) String name,
            @ApiParam(value = "状态") @RequestParam(required = false) Integer status
    ) {
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.selectByPage(pageNum, pageSize, name, status);
        return ResponseResult.success(pageInfo);
    }

    @PostMapping
    @ApiOperation(value = "新增护理信息")
    public ResponseResult<NursingProjectVo> add(@RequestBody NursingProjectDto NursingProjectDto) {
        nursingProjectService.add(NursingProjectDto);
        return  ResponseResult.success();
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理信息")
    public ResponseResult getById(@PathVariable("id") Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.getById(id);
        return ResponseResult.success(nursingProjectVo);
    }
    @DeleteMapping("{id}")
    @ApiOperation(value = "删除护理信息")
    public ResponseResult del(@PathVariable("id") Long id) {
        nursingProjectService.del(id);
        return ResponseResult.success();
    }
    @PutMapping("{id}/status/{status}")
    @ApiOperation(value = "修改护理信息状态")
    public ResponseResult updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        nursingProjectService.updateStatus(id, status);
        return ResponseResult.success();
    }
    @GetMapping("all")
    @ApiOperation(value = "查询所有护理信息" )
    public ResponseResult<List<NursingProjectVo>> selectAll() {
        return ResponseResult.success(nursingProjectService.all());
    }
    @PutMapping("{id}")
    @ApiOperation(value = "修改护理信息")
    public ResponseResult update(@RequestBody NursingProjectDto nursingProjectDto,@PathVariable Long id) {
        nursingProjectService.updete(nursingProjectDto);
        return ResponseResult.success();
    }
}
